import { nullEntity } from '$lib';
import type { Entity, IWorld } from '$lib/ecs';
import type { MeleeStyle } from './melee';
import { Agility, getStatLevel } from './stat';
import { getHandling } from './weapon';

export const getAccuracy = (world: IWorld, e: Entity, style: MeleeStyle, weapon: Entity) => {
  const agility = getStatLevel(world, e, Agility);
  const weaponAccuracy = weapon === nullEntity ? 1 : getHandling(world, weapon);
  return agility + weaponAccuracy;
};
